<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'form2.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
 <% 
    String name=request.getParameter("zhanghao" );
    String password=request.getParameter("psd" );
    Connection conn=null;
	Statement stmt=null;
	ResultSet rs=null;
	
	String url= "jdbc:mysql://localhost:3306/tsgl";
	String users = "root";
	String pass = "x5";
	
	try{
		Class.forName("com.mysql.jdbc.Driver");
		conn = DriverManager.getConnection(url,users,pass);
		stmt = conn.createStatement();
		rs = stmt.executeQuery("select account,password from zhucebiao where account='"+name+"'");
		if(rs.next()){	
				if(password.equals(rs.getString("password"))){
					response.sendRedirect("mulu.jsp");					
				}else{
				System.out.print(password +"," + rs.getString("password") + ".");
				
				out.print("账户与密码不匹配，请重新登陆");
				}
			}else{
			out.print("账户不存在，请注册");
			}
			
				
		}
	finally{
		if(rs!=null){
			rs.close();
		}
		if(stmt!=null){
			stmt.close();
		}
		if(conn!=null){
			conn.close();
		}
	}		
    
    			
  %>
   
   <br>
  </body>
</html>
